package jimo.SSMStudent.service.impl;

import jimo.SSMStudent.mapper.UsersMapper;
import jimo.SSMStudent.pojo.Users;
import jimo.SSMStudent.pojo.UsersExample;
import jimo.SSMStudent.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UsersMapper usersMapper;
    /**
     * 实现登录检验
     *
     * @param username
     * @param userpassword
     */
    @Override
    public Users longin(String username, String userpassword) {
        UsersExample usersExample = new UsersExample();
        UsersExample.Criteria criteria = usersExample.createCriteria();
        criteria.andLoginnameEqualTo(username);
        criteria.andPasswordEqualTo(userpassword);
        List<Users> users = usersMapper.selectByExample(usersExample);
        return users.size()>0?users.get(0):null;
    }
}
